package com.cat.chapter046;

import java.util.HashMap;

/**
 * @author cat
 * @description https://leetcode.cn/problems/find-the-longest-substring-containing-vowels-in-even-counts/
 * @create 2025/7/16 09:51
 * @since JDK17
 */

public class Solution06 {
    static HashMap<Integer, Integer> map = new HashMap<>();
    static char[] vowel = new char[6];
    public int want(int x) {
        for (int i = 0; i < vowel.length; i++) {
            x ^= (vowel[i] - 'a');  // 取相反数
        }
        return x;
    }
    public int findTheLongestSubstring(String s) {
        map.clear();
        map.put(0, -1);
        int ans = 0, cur = 0;
        for (int i = 0; i < s.length(); i++) {
            cur ^= 1 << (s.charAt(i) - 'a');    // 取当前值
            if (map.containsKey(cur)) {
                ans = Math.max(ans, i - map.get(cur));
            }

            if (!map.containsKey(cur)) {
                map.put(cur, i);
            }
        }

        return ans;
    }
}
